﻿#include "homewidget.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QDesktopServices>
#include <QUrl>
homeWidget::homeWidget(QWidget *parent) : QWidget(parent)
{
    QVBoxLayout *v_layout = new QVBoxLayout();
    QHBoxLayout *h_layout = new QHBoxLayout();
    QPushButton *bt1 = new QPushButton("前往gitee", this);
    QPushButton *bt2 = new QPushButton("查看最新版", this);
    bt1->setObjectName("homebtn1");
    bt2->setObjectName("homebtn2");
    h_layout->addStretch();
    h_layout->addWidget(bt1, 0, Qt::AlignTop);
    h_layout->addSpacing(100);
    h_layout->addWidget(bt2, 0, Qt::AlignTop);
    h_layout->addStretch();
    h_layout->setStretch(0, 2);
    h_layout->setStretch(1, 0);
    h_layout->setStretch(2, 0);
    h_layout->setStretch(3, 0);
    h_layout->setStretch(4, 2);
    QString data("欢迎使用CQTool，这是一个模仿网上开源作品的，但是用的是Qt Qwidget做的内容也不一样，有些界面是借鉴了点,自己闲暇业余时间的的小作品，本作品界面"
                 "用QWidget实现，逻辑用C++实现的，包含了一些常用的工具，都是大家高频使用的");
    QLabel *label = new QLabel(data, this);
    label->setAlignment(Qt::AlignCenter);
    label->setWordWrap(true);
    label->setObjectName("homeLabel");
    v_layout->addWidget(label, 0, Qt::AlignHCenter|Qt::AlignBottom);
    v_layout->addSpacing(100);
    v_layout->addLayout(h_layout);
    v_layout->setMargin(0);
    v_layout->setSpacing(0);
    this->setLayout(v_layout);
    connect(bt1, &QPushButton::clicked, this, [this]{
        QDesktopServices::openUrl(QUrl("https://gitee.com/cxtan/cQtTools"));
    });
    connect(bt2, &QPushButton::clicked, this, [this]{
        QDesktopServices::openUrl(QUrl("https://gitee.com/cxtan/cQtTools"));
    });
}
